using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using Curchy.PERTToolbox.Interface;
using System.Xml;
using System.Xml.Serialization;
using Curchy.PERTToolbox.PropertyGrid;

namespace Curchy.PERTToolbox.Entity
{
    public class Activity : IDescriptive
    {
        private string _name;
        private string _detail;

        private TimeSpan _timeFrame;

        [PropertyOrder(1)]
        [CategoryAttribute("Specifications")]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        [PropertyOrder(2)]
        [CategoryAttribute("Specifications")]
        public string Detail
        {
            get { return _detail; }
            set { _detail = value; }
        }

        [PropertyOrder(3)]
        [CategoryAttribute("Specifications")]
        [XmlIgnore]
        public TimeSpan TimeFrame
        {
            get { return _timeFrame; }
            set { _timeFrame = value; }
        }

        [Browsable(false)]
        [XmlElement("TimeFrame", DataType = "duration")]
        public string SerializableTimeFrame
        {
            get
            {
                return XmlConvert.ToString(_timeFrame);
            }
            set
            {
                _timeFrame = XmlConvert.ToTimeSpan(value);
            }
        }

        public override string ToString()
        {
            return _name;
        }

        #region IDescriptive Members

        [Browsable(false)]
        public string Description
        {
            get 
            {
                return "Timeframe: " + _timeFrame.ToString();
            }
        }

        #endregion
    }
}
